package com.ruoyi.web.controller.smartHighway;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smartHighway.domain.VersionInfo;
import com.ruoyi.smartHighway.service.IVersionInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 版本更新记录Controller
 * 
 * @author ljj
 * @date 2024-08-06
 */
@RestController
@RequestMapping("/smartHighway/versionInfo")
public class VersionInfoController extends BaseController {

    @Autowired
    private IVersionInfoService versionInfoService;

    /**
     * 查询版本更新记录列表
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(VersionInfo versionInfo) {
        startPage();
        List<VersionInfo> list = versionInfoService.selectVersionInfoList(versionInfo);
        return getDataTable(list);
    }

    /**
     * 导出版本更新记录列表
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:export')")
    @Log(title = "版本更新记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VersionInfo versionInfo) {
        List<VersionInfo> list = versionInfoService.selectVersionInfoList(versionInfo);
        ExcelUtil<VersionInfo> util = new ExcelUtil<VersionInfo>(VersionInfo.class);
        util.exportExcel(response, list, "版本更新记录数据");
    }

    /**
     * 获取版本更新记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:query')")
    @GetMapping(value = "/{versionId}")
    public AjaxResult getInfo(@PathVariable("versionId") Long versionId) {
        return success(versionInfoService.selectVersionInfoByVersionId(versionId));
    }

    /**
     * 新增版本更新记录
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:add')")
    @Log(title = "版本更新记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VersionInfo versionInfo) {
        return toAjax(versionInfoService.insertVersionInfo(versionInfo));
    }

    /**
     * 修改版本更新记录
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:edit')")
    @Log(title = "版本更新记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VersionInfo versionInfo) {
        return toAjax(versionInfoService.updateVersionInfo(versionInfo));
    }

    /**
     * 删除版本更新记录
     */
    @PreAuthorize("@ss.hasPermi('smartHighway:versionInfo:remove')")
    @Log(title = "版本更新记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{versionIds}")
    public AjaxResult remove(@PathVariable Long[] versionIds) {
        return toAjax(versionInfoService.deleteVersionInfoByVersionIds(versionIds));
    }
}
